<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class FsUserImRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            case 'POST':
                $rules =  [
                    'im_id' => [
                        'required',
                        Rule::exists('user_ims','id')->where('status',1)
                    ],
                    'ids' => 'required|array',
                    'ids.*' =>"exists:mysql_branch.fs_user,id"
                ];
                break;
            case 'PATCH':
                $rules =  [
                    'im_id' => [
                        'required',
                        Rule::exists('user_ims','id')->where('status',1)
                    ],
                    'ids' => 'required|array',
                    'ids.*' =>"exists:mysql_branch.fs_user,id"
                ];
                break;
        }

        return $rules;
    }
    public function attributes(){
        return [
            'ids'=>'会员',
            'ids.*'=>'会员'
        ];
    }

}
